<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

<link rel="stylesheet" href="${ctx}/page/lib/vue/css/common.css?v=${version}">
<link rel="stylesheet" href="${ctx}/page/lib/vue/css/swiper3.1.0.min.css">
<script type="text/javascript"  src="${ctx}/page/lib/vue/js/vue.min.js"></script>
<script type="text/javascript" src="${ctx}/page/lib/vue/js/axios.min.js"></script>
<script type="text/javascript" src="${ctx}/page/lib/vue/js/es6-promise.auto.min.js"></script>
<script type="text/javascript" src="${ctx}/page/lib/vue/js/fastclick.min.js"></script>
<script type="text/javascript" src="${ctx}/page/lib/vue/js/vue-lazyload.js"></script>
<script type="text/javascript" src="${ctx}/page/lib/vue/js/window.alert.js"></script>
<script type="text/javascript" src="${ctx}/page/lib/vue/js/validate.js"></script>

<script type="text/javascript">
	var ctx = "${ctx}";
	var pageUrl = "${pageUrl}";
	var mServerUrl = "${mServerUrl}";
	
	Origami.fastclick(document.body);
	Vue.filter("fixed2", function (value) {
		if(!value){
			return "0.00";
		}
		return value.toFixed(2);
	});
	Vue.filter("fixed4", function (value) {
		if(!value){
			return "0.0000";
		}
		return value.toFixed(4);
	});
	/**
	 * 日期格式化
	 * 
	 * @param value
	 * @param fmt 如'yyyy-MM-dd';'yyyy-MM-dd HH:mm:ss'
	 * @returns 
	 */
	Vue.filter("format", function (value,fmt) {
		var date = new Date(parseInt(value));
	    var o = {
            "M+": date.getMonth() + 1, //月份 
            "d+": date.getDate(), //日 
            "h+": date.getHours(), //小时 
            "m+": date.getMinutes(), //分 
            "s+": date.getSeconds(), //秒 
            "q+": Math.floor((date.getMonth() + 3) / 3), //季度 
            "S": date.getMilliseconds() //毫秒 
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
	});
	 
	Vue.filter("formatTime", function (value) {
    	var date = new Date(value);
    	Y = date.getFullYear(),
    	m = date.getMonth() + 1,
    	d = date.getDate(),
    	H = date.getHours(),
    	i = date.getMinutes(),
    	s = date.getSeconds();
    	if (m < 10) {
    	m = '0' + m;
    	}
    	if (d < 10) {
    	d = '0' + d;
    	}
    	if (H < 10) {
    	H = '0' + H;
    	}
    	if (i < 10) {
    	i = '0' + i;
    	}
    	if (s < 10) {
    	s = '0' + s;
    	}
    	var t = Y+'-'+m+'-'+d+' '+H+':'+i+':'+s;
    	return t;
	});
	/**
	 * 手机号隐藏中间
	 * 
	 * @param mobileNumber
	 * @returns 
	 */
	Vue.filter("encodeMobileNumber", function (mobileNumber) {
		return mobileNumber.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
	});
	
	Vue.component('my-header', {
		  template: '<div class="header">'+
			'<div class="logo"></div>'+
			'<div class="search"><form action="javascript:return true;"><input v-model="keyword" type="search" placeholder="护手霜" value="" @keypress="searchProduct"/></form>'+'</div>'+
			'</div>',
		  data:function(){
	           return {
	        	   keyword:this.value
	           }
	      },
		  props:['value'],
		  computed:{
			  keyword: {
	              get:function() {
	                  return this.value;
	               },
	               set:function(val) {
	                   this.$emit('input', val);
	               }
	           }
	       },
	       methods:{
	    	   searchProduct:function(e){
	               var keycode = e.keyCode;
	               if(keycode=='13') {  
	                   e.preventDefault();
	                   if(this.keyword){
		                   window.location.href=mServerUrl+"/page/searchList.htm?keyword="+this.keyword;
	                   }else{
	                	   window.location.href=mServerUrl+"/page/searchList.htm";
	                   }
	               }
	    	   },
	       }
		});
	
</script>


